package com.cmc.cloud.cmclink.doc.controller.admin.si;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.excel.EasyExcel;
import com.cmc.cloud.cmclink.doc.api.document.BaseCodeQueryApi;
import com.cmc.cloud.cmclink.doc.api.document.rep.BaseCodeRpcRepDto;
import com.cmc.cloud.cmclink.doc.api.document.req.so.SoForecastRespVO;
import com.cmc.cloud.cmclink.doc.configuration.CommonConfiguration;
import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.convert.BlnoConvert;
import com.cmc.cloud.cmclink.doc.entity.BlnoDO;
import com.cmc.cloud.cmclink.doc.framework.listener.HsCodeExcelListener;
import com.cmc.cloud.cmclink.doc.service.si.BlnoService;
import com.cmc.cloud.cmclink.doc.vo.blnocntrvo.CntrBaseInfoVO;
import com.cmc.cloud.cmclink.doc.vo.blnovo.*;
import com.cmc.cloud.cmclink.doc.vo.blnovo.operatevo.BlnoOperateReqVO;
import com.cmc.cloud.cmclink.doc.vo.hscodevo.HsCodeExportVo;
import com.cmc.cloud.cmclink.doc.vo.hscodevo.HsCodeImportVo;
import com.cmc.cloud.cmclink.doc.vo.sovo.operatelog.OperateLogRespVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import com.cmes.framework.excel.core.util.ExcelUtils;
import com.cmes.framework.operatelog.core.annotations.OperateLog;
import com.cmes.framework.operatelog.core.enums.OperateTypeEnum;
import com.cmes.framework.security.core.util.SecurityFrameworkUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import static com.cmc.cloud.cmclink.doc.api.document.emums.CntaoCntrCompareTypeEnum.CNTR_TYPE_SIZE_DIFFERENT;
import static com.cmc.cloud.cmclink.doc.api.document.emums.CntaoCntrCompareTypeEnum.MA_TOU_HAVE;
import static com.cmc.cloud.cmclink.doc.api.document.emums.CntaoCntrCompareTypeEnum.POD_DIFFERENT;
import static com.cmc.cloud.cmclink.doc.api.document.emums.CntaoCntrCompareTypeEnum.XIANG_YUN_HAVE;


/**
 * 提单主信息前端接口Controller
 *
 * @author codegen
 */
@Tag(name = "管理后台 - 提单主信息")
@RestController
@Validated
@RequestMapping(UrlConstants.APPLICATION_URL + "/blno")
public class BlnoController {

    @Resource
    private BlnoService blnoService;
    @Resource
    private BaseCodeQueryApi baseCodeQueryApi;





    @Operation(summary = "创建提单主信息")
    @OperateLog(type = OperateTypeEnum.CREATE)
    @PostMapping("/create")
    public CommonResult<Void> createBlno(@Valid @RequestBody BlnoCreateReqVO createReqVO) {
        blnoService.createBlno(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新提单主信息")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/update")
    public CommonResult<Void> updateBlno(@Valid @RequestBody BlnoUpdateReqVO updateReqVO) {
        blnoService.updateBlno(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除提单主信息")
    @OperateLog(type = OperateTypeEnum.DELETE)
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('doc:maintainBL:delete')")
    @PostMapping("/delete/{id}")
    public CommonResult<Void> deleteBlno(@PathVariable("id") Long id) {
        blnoService.deleteBlno(id);
        return CommonResult.success();
    }

    @Operation(summary = "将提单退回为草稿状态")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @Parameter(name = "id", description = "编号", required = true)
    @PostMapping("/returnDraft/{id}")
    public CommonResult<Void> returnDraft(@PathVariable("id") Long id){
        blnoService.returnDraft(id);
        return CommonResult.success();
    }

    @Operation(summary = "提交提单主信息")
    @OperateLog(type = OperateTypeEnum.CREATE)
    @PostMapping("/commit")
    public CommonResult<Void> commitSi(@Valid @RequestBody BlnoInfoVO blnoInfoVO) {
        blnoService.commitSi(blnoInfoVO);
        return CommonResult.success();
    }

    /**
     * 创建si 更改记录
     * @param createReqVO
     * @return void
     */
    @Operation(summary = "创建si 更改记录")
    @PostMapping("/createSiChange")
    @OperateLog(type = OperateTypeEnum.CREATE)
    public CommonResult<Void> createSiChange(@Valid @RequestBody BlnoInfoVO createReqVO){
        blnoService.createSiChange(createReqVO);
        return CommonResult.success();
    }

    /**
     * 判断是否可以 创建si 更改记录
     * @param id 提单主表id
     * @return void
     */
    @Operation(summary = "判断是否可以 创建si 更改记录")
    @OperateLog(type = OperateTypeEnum.OTHER)
    @PostMapping("/checkSiChange/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<Boolean> checkSiChange(@PathVariable("id") Long id){
        return CommonResult.success(blnoService.checkSiChange(id));
    }

    @Operation(summary = "获得提单主信息")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/get/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<BlnoRespVO> getBlno(@PathVariable("id") Long id) {
        BlnoDO blno = blnoService.getBlno(id);
        return CommonResult.success(BlnoConvert.INSTANCE.convert(blno));
    }

    @Operation(summary = "获得提单主信息和子信息")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/detail/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission({'doc:maintainBL:preview','doc:checkSi:preview','doc:operateBL:preview','doc:billLoadingOperation:preview'})")
    @UseResponsePropertyAdvice
    public CommonResult<BlnoInfoVO> getSiDetail(@PathVariable("id") Long blnoId) {
        BlnoInfoVO siDetail = blnoService.getSiDetail(blnoId);
        return CommonResult.success(siDetail);
    }

    @Operation(summary = "根据箱号获取箱基础信息")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/getContainInfo")
    public CommonResult<CntrBaseInfoVO> getContainInfo (@RequestParam("containNo") String containNo){
        CntrBaseInfoVO containInfo = blnoService.getContainInfo(containNo);
        return CommonResult.success(containInfo);
    }

    @Operation(summary = "获得提单主信息列表")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/list")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    public CommonResult<List<BlnoRespVO>> getBlnoList(@RequestParam("ids") Collection<Long> ids) {
        List<BlnoDO> list = blnoService.getBlnoList(ids);
        return CommonResult.success(BlnoConvert.INSTANCE.convertList(list));
    }

    @Operation(summary = "获得提单主信息分页")
    @OperateLog(type = OperateTypeEnum.GET)
    @PostMapping("/page")
    @PreAuthorize("@ss.hasPermission({'doc:maintainBL:search','doc:checkSi:preview','doc:operateBL:search'})")
    public CommonResult<PageResult<BlnoPageRespVO>> getBlnoPage(@Valid @RequestBody BlnoPageReqVO pageVO) {
        PageResult<BlnoPageRespVO> blnoPage = blnoService.getBlnoPage(pageVO);
        return CommonResult.success(blnoPage);
    }

    @Operation(summary = "创建SI")
    @OperateLog(type = OperateTypeEnum.CREATE)
    @PostMapping("/createSi")
    @PreAuthorize("@ss.hasPermission('doc:maintainBL:add')")
    public CommonResult<Long> createSi(@Valid @RequestBody BlnoInfoVO createReqVO) {
        return CommonResult.success(blnoService.createOrUpdateSi(createReqVO, false, String.valueOf(SecurityFrameworkUtils.getLoginUserId())));
    }

    @Operation(summary = "更新SI")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/updateSi")
    @PreAuthorize("@ss.hasPermission('doc:maintainBL:edit')")
    public CommonResult<Long> updateSi(@Valid @RequestBody BlnoInfoVO updateReqVO) {
        return CommonResult.success(
            blnoService.createOrUpdateSi(updateReqVO, true, String.valueOf(SecurityFrameworkUtils.getLoginUserId())));
    }

    @GetMapping("/excel-export")
    @Operation(summary = "excel导出")
    @OperateLog(type = OperateTypeEnum.EXPORT)
    @Parameter(name = "bookingNo", description = "订舱号")
    @Parameter(name = "blNo", description = "提单号")
    @Parameter(name = "bkgVesselCode", description = "订舱船名")
    @Parameter(name = "bkgVoyage", description = "订舱航次")
    @Parameter(name = "porCode", description = "接货地")
    @Parameter(name = "polCode", description = "装货港")
    @Parameter(name = "bkpCode", description = "订舱人代码")
    @PreAuthorize("@ss.hasPermission('doc:maintainBL:export')")
    public void exportExcelTemplate(HttpServletResponse response, @RequestParam(value = "bookingNo", required = false) String bookingNo
            , @RequestParam(value = "blNo", required = false) String blNo
            , @RequestParam(value = "bkgVesselCode", required = false) String bkgVesselCode
            , @RequestParam(value = "bkgVoyage", required = false) String bkgVoyage
            , @RequestParam(value = "porCode", required = false) String porCode
            , @RequestParam(value = "polCode", required = false) String polCode
            , @RequestParam(value = "bkpCode", required = false) String bkpCode) throws IOException {
        List<BlnoPageRespVO> exportList = blnoService.getExportList(BlnoBaseInfoExportVO.builder()
                .blNo(blNo).bookingNo(bookingNo).bkgVesselCode(bkgVesselCode).bkgVoyage(bkgVoyage).porCode(porCode).polCode(polCode).bkpCode(bkpCode).build());
        // FIXME 一定要向response写数据之前设置响应头，否则会出现文件下载失败
        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("SI.xlsx", StandardCharsets.UTF_8.name()));
        response.setContentType("application/vnd.ms-excel;charset=UTF-8");
        ExcelUtils.write(response, "SI.xls", "模版", BlnoPageRespVO.class, exportList);
    }

    @Operation(summary = "获得中转船名航次信息")
    @GetMapping("/getBlnoAll")
    @OperateLog(type = OperateTypeEnum.GET)
    @PreAuthorize("@ss.hasPermission('doc:setupTransshipment:search')")
    public CommonResult<List<BlnoTransferVO>> getBlnoAll(@Valid BlnoTransferVO reqVO) {
        return CommonResult.success(blnoService.getBlnoAll(reqVO));
    }

    /**
     * 设置 提单打印地
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "设置 提单打印地")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/setIssuePlace")
    @PreAuthorize("@ss.hasPermission('doc:operateBL:setIssuePlace')")
    public CommonResult<Void> setIssuePlace(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.setIssuePlace(blnoOperateReqVO);
        return CommonResult.success();
    }


    /**
     * 设置 提单打印日期
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "设置 提单打印日期")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/setIssueDate")
    @PreAuthorize("@ss.hasPermission('doc:operateBL:setIssueDate')")
    public CommonResult<Void> setIssueDate(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.setIssueDate(blnoOperateReqVO);
        return CommonResult.success();
    }


    /**
     * 设置 实际签单类型
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "设置 实际签单类型")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/operateSignType")
    @PreAuthorize("@ss.hasPermission({'doc:operateBL:signBL','doc:billLoadingOperation:signBlType'})")
    public CommonResult<Void> operateSignType(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.operateSignType(blnoOperateReqVO);
        return CommonResult.success();
    }


    /**
     * 设置 电子保函登记类型
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "设置 电子保函登记类型")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/setElgReceive")
    @PreAuthorize("@ss.hasPermission('doc:operateBL:receiveELG')")
    public CommonResult<Void> setElgReceive(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.setElgReceive(blnoOperateReqVO);
        return CommonResult.success();
    }


    /**
     * 设置 正本保函登记类型
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "设置 正本保函登记类型")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/setLgReceive")
    @PreAuthorize("@ss.hasPermission('doc:operateBL:receiveLG')")
    public CommonResult<Void> setLgReceive(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.setLgReceive(blnoOperateReqVO);
        return CommonResult.success();
    }


    /**
     * 设置 扣单标记
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "设置 扣单标记")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/signRestriction")
    @PreAuthorize("@ss.hasPermission('doc:operateBL:signRestriction')")
    public CommonResult<Void> signRestriction(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.signRestriction(blnoOperateReqVO);
        return CommonResult.success();
    }

    /**
     * 锁定提单
     * @param blnoOperateReqVO
     * @return
     */
    @Operation(summary = "设置 锁单标记")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/setBlLock")
    @PreAuthorize("@ss.hasPermission({'doc:operateBL:lockSi','doc:billLoadingOperation:lockSi'})")
    public CommonResult<Void> setBlLock(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO){
        blnoService.setBlLock(blnoOperateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "check SI")
    @OperateLog(type = OperateTypeEnum.OTHER)
    @PostMapping("/checkSi")
    public CommonResult<BlnoCheckSiRespVO> checkSi(@Valid @RequestBody BlnoCheckSiReqVO blnoCheckSiReqVO) {
        return CommonResult.success(blnoService.checkSi(blnoCheckSiReqVO));
    }

    @Operation(summary = "confirm SI")
    @PostMapping("/confirmSi")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    public CommonResult<BlnoCheckSiRespVO> confirmSi(@Valid @RequestBody BlnoCheckSiReqVO blnoCheckSiReqVO,
        HttpServletResponse httpServletResponse) {
        blnoCheckSiReqVO.setResponse(httpServletResponse);
        return CommonResult.success(blnoService.confirmSi(blnoCheckSiReqVO));
    }

    /**
     * 取消 扣单 标记
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "取消 扣单标记")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/cancelRestriction")
    @PreAuthorize("@ss.hasPermission('doc:operateBL:cancelRestriction')")
    public CommonResult<Void> cancelRestriction(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.cancelRestriction(blnoOperateReqVO);
        return CommonResult.success();
    }


    /**
     * 清空 originalBl
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "清空 originalBl")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/cancelOriginalBl")
    @PreAuthorize("@ss.hasPermission({'doc:operateBL:cancelOriginal','doc:billLoadingOperation:cancelOriginal'})")
    public CommonResult<Void> cancelOriginalBl(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.cancelOriginalBl(blnoOperateReqVO);
        return CommonResult.success();
    }

    /**
     * 清空 telex
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = " 清空 telex")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/cancelTelex")
    @PreAuthorize("@ss.hasPermission({'doc:operateBL:cancleTelexSeaway','doc:billLoadingOperation:cancleTelexSeaway'})")
    public CommonResult<Void> cancelTelex(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.cancelTelex(blnoOperateReqVO);
        return CommonResult.success();
    }


    /**
     * 清空 electronicBl
     *
     * @param blnoOperateReqVO
     * @return List<BlnoDO>
     */
    @Operation(summary = "清空 electronicBl")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/cancelElectronicBl")
    @PreAuthorize("@ss.hasPermission({'doc:operateBL:cancelElectronicBL','doc:billLoadingOperation:cancelElectronicBL'})")
    public CommonResult<Void> cancelElectronicBl(@Valid @RequestBody BlnoOperateReqVO blnoOperateReqVO) {
        blnoService.cancelElectronicBl(blnoOperateReqVO);
        return CommonResult.success();
    }


    @Operation(summary = "获得提单的操作日志信息")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/operationLog/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @UseResponsePropertyAdvice
    public CommonResult<List<OperateLogRespVO>> getSiOperationLog(@PathVariable("id") Long blnoId) {
        List<OperateLogRespVO> siOperationLogs = blnoService.getSiOperationLog(blnoId);
        return CommonResult.success(siOperationLogs);
    }

    /**
     * 返回true 弹出提示给用户确认
     * @param assertNoticeVO
     * @return Boolean
     */
    @Operation(summary = "弹出提示给用户确认")
    @OperateLog(type = OperateTypeEnum.OTHER)
    @PostMapping("/assertGiveNotice")
    public CommonResult<Boolean> assertGiveNotice(@Valid @RequestBody AssertNoticeVO assertNoticeVO){
        return CommonResult.success(blnoService.assertGiveNotice(assertNoticeVO));
    }

    @Operation(summary = "多so合si 校验")
    @OperateLog(type = OperateTypeEnum.OTHER)
    @PostMapping("/checkSoCombineSi")
//    @PreAuthorize("@ss.hasPermission('doc:operateBL:cancelElectronicBL')")
    public CommonResult<Void> checkSoCombineSi(@Valid @RequestBody BlnoMultipleSoVO blnoMultipleSoVO) {
        blnoService.checkSoCombineSi(blnoMultipleSoVO);
        return CommonResult.success();
    }

    @Operation(summary = "多so合si 保存草稿")
    @OperateLog(type = OperateTypeEnum.CREATE)
    @PostMapping("/createSoCombineSi")
    @PreAuthorize("@ss.hasPermission('doc:maintainBL:multipleSO')")
    public CommonResult<Void> createSoCombineSi(@Valid @RequestBody BlnoMultipleSoCreateVO blnoMultipleSoCreateVO) {
        blnoService.createSoCombineSi(blnoMultipleSoCreateVO);
        return CommonResult.success();
    }

    @Operation(summary = "多so合si 提交")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/commitSoCombineSi")
    public CommonResult<Void> commitSoCombineSi(@Valid @RequestBody BlnoMultipleSoCreateVO blnoMultipleSoCreateVO) {
        blnoService.commitSoCombineSi(blnoMultipleSoCreateVO);
        return CommonResult.success();
    }

    @Operation(summary = "获取多个so的 预配箱信息")
    @OperateLog(type = OperateTypeEnum.GET)
    @PostMapping("/getForecastInfo")
    public CommonResult<List<SoForecastRespVO>> getForecastInfo(@RequestBody BlnoForecastReqVO blnoForecastReqVO){
        return CommonResult.success(blnoService.getForecastInfo(blnoForecastReqVO));
    }

    @Operation(summary = "青岛码头数据对比 自有数据")
    @OperateLog(type = OperateTypeEnum.GET)
    @PostMapping("/selectCntaoCntr")
    public CommonResult<List<BlnoCntrCntaoVO>> selectCntaoCntr(@RequestBody BlnoCntrCntaoReqVO blnoCntrCntaoReqVO){
        return CommonResult.success(blnoService.selectCntaoCntr(blnoCntrCntaoReqVO));
    }

    @OperateLog(type= OperateTypeEnum.EXPORT)
    @PostMapping("/excel-template")
    @Operation(summary = "导出青岛码头箱数据对比结果")
    @PreAuthorize("@ss.hasPermission('doc:checkMT_CNTAO:toExcel')")
    public void downloadExcelTemplateImport(HttpServletResponse response,@RequestBody @Valid List<BlnoCntrCntaoCompareVO> blnoCntrCntaoCompareVos) throws IOException {
        blnoCntrCntaoCompareVos.forEach(n->{
            if(XIANG_YUN_HAVE.getValue().equals(n.getDifferType())){
                n.setDifferType(XIANG_YUN_HAVE.getLabel());
            }else if(MA_TOU_HAVE.getValue().equals(n.getDifferType())){
                n.setDifferType(MA_TOU_HAVE.getLabel());
            }else if(POD_DIFFERENT.getValue().equals(n.getDifferType())){
                n.setDifferType(POD_DIFFERENT.getLabel());
            }else if(CNTR_TYPE_SIZE_DIFFERENT.getValue().equals(n.getDifferType())){
                n.setDifferType(CNTR_TYPE_SIZE_DIFFERENT.getLabel());
            }
        });
        // FIXME 一定要向response写数据之前设置响应头，否则会出现文件下载失败
        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("Check_MT.xlsx", StandardCharsets.UTF_8.name()));
        response.setContentType("application/vnd.ms-excel;charset=UTF-8");
        ExcelUtils.write(response, "Check_MT.xlsx", "result", BlnoCntrCntaoCompareVO.class, blnoCntrCntaoCompareVos);

    }

    @OperateLog(type= OperateTypeEnum.IMPORT)
    @PostMapping(value = "/cntaoImport", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @Operation(summary = "青岛码头箱数据对比")
    @PreAuthorize("@ss.hasPermission('doc:checkMT_CNTAO:check')")
    public CommonResult<BlnoCntrCntaoCompareRespVO> excelCreateImport(@RequestPart @RequestParam(value ="file") MultipartFile file
            ,@RequestParam(value = "portCode") String portCode
            , @RequestParam(value = "bkgVesselCode") String bkgVesselCode
            ,@RequestParam(value = "bkgVoyage") String bkgVoyage) throws IOException {
        BlnoCntrCntaoReqVO blnoCntrCntaoReqVO = BlnoCntrCntaoReqVO.builder().file(file).bkgVesselCode(bkgVesselCode).bkgVoyage(bkgVoyage).portCode(portCode).build();
        return CommonResult.success( blnoService.checkCntaoCntr(blnoCntrCntaoReqVO));
    }

    @PostMapping("/checkCpfCode")
    public CommonResult<List<BaseCodeRpcRepDto>> checkCpfCode(){
        return CommonResult.success();
    }
}
